Skip to content

fix(backend): standardize timezone handling to UTC ISO-8601#2033

Merged
NaitikVerma6776 merged 2 commits into
utksh1:mainfrom
NaitikVerma6776:cursor/utc-timezone-standardize-9bb6
Jul 22, 2026
Merged

fix(backend): standardize timezone handling to UTC ISO-8601#2033
NaitikVerma6776 merged 2 commits into
utksh1:mainfrom
NaitikVerma6776:cursor/utc-timezone-standardize-9bb6

Conversation

@NaitikVerma6776

Copy link
Copy Markdown
Collaborator

Add shared time_utils helpers and use timezone-aware UTC with an explicit offset for generated_at and discovered_at across reports, findings API responses, and report generation.

Closes #1882

What changed
Added backend/secuscan/time_utils.py for shared UTC helpers
Reports now emit UTC ISO-8601 generated_at / discovered_at (with offset)
Findings/reports API responses normalize timestamps to UTC with offset
_parse_discovered_at always returns timezone-aware UTC
Added unit tests for UTC parsing/formatting + frontend date consistency

@NaitikVerma6776 NaitikVerma6776 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:refactor Refactor work category bonus label gssoc:approved Admin validation: approved for GSSoC scoring area:backend Backend API, database, or service work labels Jul 15, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good technical improvement! Standardizes timezone handling to always use timezone-aware UTC with ISO-8601 formatting.

Key improvements:
✅ Added time_utils.py with shared UTC helpers (utc_now, parse_to_utc, to_utc_iso)
✅ Reports now emit consistent generated_at/discovered_at timestamps
✅ All datetime handling is timezone-aware
✅ Added unit tests for UTC parsing/formatting

This prevents timezone-related bugs and improves timestamp consistency across reports, findings, and API responses. All CI checks passed. Approved for merge.

@utksh1

utksh1 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Great work on this timezone standardization! The PR is approved, but needs a rebase with main due to conflicts:

Conflicts:

  1. backend/secuscan/reporting.py - conflicts with Fix: Redact target field and recursively redact evidence (#17) #2042's evidence redaction
  2. testing/backend/unit/test_tls_verification.py - conflicts with fix: resolve TypeError in TLS verification unit tests-#1414 #2040/fix(plugins): enforce strict validation and integrity checks for missing custom parser #1812 #2041's test helper refactoring

Both conflicts are straightforward:

  • In reporting.py, keep both changes: to_utc_iso() for discovered_at AND _redact_value() for evidence
  • In test file, use main's _make_mock_stream_response() helper approach instead of the custom _mock_async_client() helper

Once rebased, I'll merge immediately since it's already approved!

Add shared time_utils helpers and use timezone-aware UTC with an
explicit offset for generated_at and discovered_at across reports,
findings API responses, and report generation.

Closes utksh1#1882
Default to_utc_iso to timespec=auto so finding intelligence tests can
compare against datetime.now(UTC). Update TLS verification mocks for
crawler client.stream() and stub crawl_target in API scanner tests.
@cursor
cursor Bot force-pushed the cursor/utc-timezone-standardize-9bb6 branch from 683843a to 396a889 Compare July 21, 2026 10:50
@NaitikVerma6776
NaitikVerma6776 merged commit caf6b04 into utksh1:main Jul 22, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work gssoc:approved Admin validation: approved for GSSoC scoring level:intermediate 35 pts difficulty label for moderate contributor PRs type:refactor Refactor work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#97] Improvement: Standardize timezone handling (UTC everywhere) in API + reports

2 participants